package com.isay.frameworklib.adapter;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public class MyViewPagerAdapter extends PagerAdapter {
	
	private List<View> mList = new ArrayList<View>();
	
	public MyViewPagerAdapter(){
		super();
	}
	
	public void setList(List<View> list) {
		mList.clear();
		mList.addAll(list);
	}
	

	@Override
	public int getCount() {
		return mList.size();
	}

	@Override
	public void destroyItem(View arg0, int arg1, Object arg2) {
		((ViewPager) arg0).removeView((View) arg2);
	}

	@Override
	public Object instantiateItem(View arg0, int arg1) {
		((ViewPager) arg0).addView(mList.get(arg1), 0);
		return mList.get(arg1);
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == (arg1);
	}

}
